package group.newsReader.Controller;

import group.newsReader.Pojo.History;
import group.newsReader.Pojo.News;
import group.newsReader.Service.NewsService;
import group.newsReader.Service.NlpService;
import group.newsReader.Utils.ApiUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RestController
public class NewsController {
    @Autowired
    private ApiUtil apiUtil;
    @Autowired
    private NewsService newsService;
    @Autowired
    private NlpService nlpService;
    @GetMapping("/saveNews")
    public void saveNews(){
        newsService.saveNews();
    }
    @GetMapping("/getNews")
    public List<News> getNews(){
        return newsService.getNews();
    }
    @GetMapping("/getDeepSeek")
    public String getDeepSeek(String query) throws IOException, InterruptedException {
        return nlpService.getDeepSeek(query);
    }
    @GetMapping("/recommend")
    public List<News> recommend(){
        return newsService.recommend();
    }
    @GetMapping("insertNews")
    public String insertNews(News news){
        return newsService.insertNews(news);
    }
    @GetMapping("news")
    public News news(int id){
        return newsService.news(id);
    }
    @PostMapping("translate")
    public String translate(String content) throws IOException, InterruptedException {
        return nlpService.translate(content);
    }
    @GetMapping("history")
    public List<History>history(){
        return newsService.history();
    }
    @GetMapping("addHistory")
    public void addHistory(int id,String title){
        newsService.addHistory(id,title);
    }
    @GetMapping("deleteHistory")
    public void deleteHistory(int id){
        newsService.deleteHistory(id);
    }
    @PostMapping("generateQuestions")
    public String generateQuestions(String content) throws IOException, InterruptedException {
        return nlpService.generateQuestions(content);
    }
    @GetMapping("vector")
    public void vector(){
        newsService.vector();
    }
}
